package com.boxuegu.guanweihua25.boxuegudatabinding;

import android.databinding.DataBindingUtil;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.boxuegu.guanweihua25.boxuegudatabinding.databinding.ActivityMainBinding;
import com.boxuegu.guanweihua25.boxuegudatabinding.fragment.CourseFragment;
import com.boxuegu.guanweihua25.boxuegudatabinding.fragment.MeFragment;
import com.boxuegu.guanweihua25.boxuegudatabinding.fragment.PracticeFragment;

public class MainActivity extends AppCompatActivity {
    Fragment meFragment =new MeFragment();
    Fragment courseFragment=new CourseFragment();
    Fragment practiceFragment=new PracticeFragment();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ActivityMainBinding binding= DataBindingUtil.setContentView(this,R.layout.activity_main);
//        setContentView(R.layout.activity_main);

        binding.couselayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getSupportFragmentManager().beginTransaction().replace(R.id.layout,courseFragment).commit();
                binding.couselayout.setSelected(true);
                binding.practicelayout.setSelected(false);
                binding.mylayout.setSelected(false);
            }
        });
binding.practicelayout.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        getSupportFragmentManager().beginTransaction().replace(R.id.layout,practiceFragment).commit();
        binding.couselayout.setSelected(false);
        binding.practicelayout.setSelected(true);
        binding.mylayout.setSelected(false);
    }
});
binding.mylayout.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        getSupportFragmentManager().beginTransaction().replace(R.id.layout,meFragment).commit();
        binding.couselayout.setSelected(false);
        binding.practicelayout.setSelected(false);
        binding.mylayout.setSelected(true);
    }
});
    }
}
